const state = {
	count: 0,
	items: []
}

const mutations = {
	addVal(state, i) {
		state.items[i].num++
	},
	getList_m(state, items) {
		state.items = items
	},
	delList_m(state, item) {
		state.items.splice(item.i, 1)
	},
	reduce_m: (state, i) => {
		state.items[i].num--
	}
}

const actions = {
	add({
		commit
	}, i) {
		commit('addVal', i)
	},
	getList({
		commit
	}, amount) {
		let items = [{
			id: 0,
			label: '个数',
			num: 1
		}, {
			id: 1,
			label: '个数',
			num: 2
		}]
		commit('getList_m', items)
	},
	del({
		commit
	}, item) {
		commit('delList_m', item)
	},
	reduce({
		commit
	}, i) {
		commit('reduce_m', i)
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}
